package com.om.calculator;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

public class BinaryOperatorTest {
    @Test
    public void performOperationCalledWithCorrectOperands() {
        BinaryOperator operatorSpy = new BinaryOperator() {
            public int actualLefOperator;
            public int actualRightOperator;
            
            @Override
            protected int performOperation(int leftOperand, int rightOperand) {
                actualLefOperator = leftOperand;
                actualRightOperator = rightOperand;
                return 0;
            }
        };
        
        OperandStack stack = new OperandStack();
        int actualLeftOperand = 97;
        stack.push(actualLeftOperand);

        int actualRightOperand = -43;
        stack.push(actualRightOperand);
        
        assertEquals(actualLeftOperand, operatorSpy.actualLefOperator);
    }

    @Test
    public void resultPutOnStack() {

        BinaryOperator operator = new BinaryOperator() {
            @Override
            protected int performOperation(int leftOperand, int rightOperand) {
                return 79;
            }
        };

        OperandStack stack = new OperandStack();
        operator.execute(stack);
        assertEquals(79, stack.top());
    }
}